import * as type from './mutation-types'
import * as API from './api'
import { ajax } from '@/assets/js/fetch'

//查询 FAQ 点击数据统计
export const setV2Faq = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.SETV2FAQ_REQUEST, data)
        // http 请求
    return ajax.post(
        API.setV2Faq, {
            commit
        },
        data,
        type.SETV2FAQ_RECEIVE
    )
};

//查询未阅读表单数量
export const getV2Faq = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.GETV2FAQ_REQUEST, data)
        // http 请求
    return ajax.get(
        API.getV2Faq, {
            commit
        },
        data,
        type.GETV2FAQ_RECEIVE
    )
};

//更新 FAQ 工单已读状态
export const delV2Faq = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.DELV2FAQ_REQUEST, data)
        // http 请求
    return ajax.postFile(
        API.delV2Faq, {
            commit
        },
        data,
        type.DELV2FAQ_RECEIVE
    )
};

//查询单个工单表单列表
export const getV2FaqCond = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.GETV2FAQCOND_REQUEST, data)
        // http 请求
    return ajax.get(
        API.getV2FaqCond, {
            commit
        },
        data,
        type.GETV2FAQCOND_RECEIVE
    )
};

//配置 FAQ 多语言
export const dragV2Faq = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.DRAGV2FAQ_REQUEST, data)
        // http 请求
    return ajax.post(
        API.dragV2Faq, {
            commit
        },
        data,
        type.DRAGV2FAQ_RECEIVE
    )
};

//查询 FAQ 多语言
export const getV2FaqParents = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.GETV2FAQPARENTS_REQUEST, data)
        // http 请求
    return ajax.get(
        API.getV2FaqParents, {
            commit
        },
        data,
        type.GETV2FAQPARENTS_RECEIVE
    )
};

//查询 FORM 表单列表
export const getV2FormList = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.GETV2FORMLIST_REQUEST, data)
        // http 请求
    return ajax.get(
        API.getV2FormList, {
            commit
        },
        data,
        type.GETV2FORMLIST_RECEIVE
    )
};

//查询用户工单列表
export const getV2FaqUList = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.GETV2FAQULIST_REQUEST, data)
        // http 请求
    return ajax.get(
        API.getV2FaqUList, {
            commit
        },
        data,
        type.GETV2FAQULIST_RECEIVE
    )
};

//提交转发的工单信息
export const submitFeMsg = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.SUBMITFEMSG_REQUEST, data)
        // http 请求
    return ajax.post(
        API.submitFeMsg, {
            commit
        },
        data,
        type.SUBMITFEMSG_RECEIVE
    )
};
//表单详情
export const formDetail = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.FORMINFO_REQUEST, data)
        // http 请求
    return ajax.get(
        API.formInfo, {
            commit
        },
        data,
        type.FORMINFO_RECEIVE
    )
};
//消息推送
export const messagePush = ({ commit }, data) => {
    // http 请求前分发action
    commit(type.MESSAGEPUSH_REQUEST, data)
        // http 请求
    return ajax.postFile(
        API.messagePush, {
            commit
        },
        data,
        type.MESSAGEPUSH_RECEIVE
    )
};
// 补充工单 uniqueId 信息  
export const addUniqueId = ({ commit }, data) => {
    commit(type.ADDUNIQUEID_REQUEST, data);
    return ajax.post(
        API.addUniqueId,
        { commit },
        data,
        type.ADDUNIQUEID_RECEIVE
    );
};
// 下载批量创建 Excel 模版  
export const getBatchTemplate = ({ commit }, data) => {
    commit(type.BATCHTEMPLATE_REQUEST, data);
    return ajax.get(
        API.getBatchTemplate,
        { commit },
        data,
        type.BATCHTEMPLATE_RECEIVE
    );
};